#include <bits/stdc++.h>
#define exp 1e-5
using namespace std;
struct car{
	int d, v, a;
	double l, r;
}b[100005];
struct carr{
	double l, r;
}c[100005];
struct ppp{
	set<int>ss;
}e[100005];
map<int, int>mp;
set<int>pp;
int p[100005], h[100005], T, n, m, L, V;
int read(){
	char c = getchar();
	while(c != '-' && !isdigit(c)) c = getchar();
	int ch = 1;
	if(c == '-'){
		ch = -1;
		c = getchar();
	}
	int h = 0;
	while(isdigit(c)){
		h = h * 10 + (int)(c - 48);
		c = getchar();
	}
	h *= ch;
	return h;
}
bool cmp(car a, car b){
	if(abs(a.l - b.l) > exp) return a.l < b.l;
	return a.r <= b.r;
}
bool cmpp(ppp a, ppp b){
	return a.ss.size() >= b.ss.size();
}
void work(){
	n = read();
	m = read();
	L = read();
	V = read();
	memset(b, 0, sizeof(b));
	for(int i = 1;i <= n;++i){
		b[i].d = read();
		b[i].v = read();
		b[i].a = read();
		if(b[i].v <= V && b[i].a <= 0){
			b[i].l = b[i].r = -1;
			continue;
		}
		if(b[i].v > V && b[i].a >= 0){
			b[i].l = b[i].d;
			b[i].r = L;
			continue;
		}
		double s = (V * V - b[i].v * b[i].v) * 1.0 / 2 / b[i].a;
		if(-s > exp){
			b[i].l = b[i].r = -1;
			continue;
		}
		if(b[i].d + s - L > exp){
			b[i].l = b[i].r = -1;
			continue;
		}
		if(b[i].a < 0){
			b[i].l = b[i].d;
			if(b[i].d + s - L > exp) b[i].r = L;
			else b[i].r = b[i].d + s;
		}
		else if(b[i].a > 0){
			b[i].l = b[i].d + s;
			b[i].r = L;
		}
	}
	sort(b + 1, b + n + 1, cmp);
	mp.clear();
	for(int i = 1;i <= m;++i){
		p[i] = read();
		mp[p[i]] = i;
	}
	int x = 1, y = 1, cnt = 0;
	pp.clear();
	memset(h, 0, sizeof(h));
	for(int i = 1;i <= m;++i)
		e[i].ss.clear();
	while(x <= n && y <= m){
		if(b[x].l == -1 || b[x].r == -1){
			++x;
			continue;
		}
		if(p[y] - b[x].r > exp){
			++x;
			continue;
		}
		if(b[x].l - p[y] > exp){
			++y;
			continue;
		}
		c[++cnt].l = b[x].l;
		c[cnt].r = b[x].r;
		for(int i = y;i <= m;++i){
			if(p[i] - b[x].r > exp) break;
			++h[x];
			pp.insert(i);
			e[i].ss.insert(p[x]);
		}
		++x;
	}
	cout << cnt << ' ';
	sort(e + 1, e + m + 1, cmpp);
	int cnnt = pp.size(), ans = 0;
	for(int i = cnnt;i >= 1;--i){
		bool f = true;
		set<int>::iterator it;
		for(it = e[i].ss.begin();it != e[i].ss.end();++it)
			if(h[mp[*it]] == 1){
				f = false;
				break;
			}
		if(!f) continue;
		++ans;
		for(it = e[i].ss.begin();it != e[i].ss.end();++it)
			--h[mp[*it]];
	}
	cout << ans << '\n';
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	T = read();
	for(int i = 1;i <= T;++i)
		work();
	return 0;
}
